﻿define(['knockout', 'getTemplateNode'], function (ko, getTemplateNode) {
    "use strict";

    var engine = new ko.nativeTemplateEngine();

    //modified template source
    engine.makeTemplateSource = function (template, templateDocument) {
        // Named template
        if (typeof template == "string") {
            return new ko.templateSources.domElement(getTemplateNode(template, templateDocument));
        } else if ((template.nodeType == 1) || (template.nodeType == 8)) {
            // Anonymous template
            return new ko.templateSources.anonymousTemplate(template);
        } else
            throw new Error("Unknown template type: " + template);
    };

    ko.setTemplateEngine(engine);
});